# Maintainer: Hoang Nguyen <folliekazetani@protonmail.com>
pkgname=hubble-cli
pkgver=0.12.3
pkgrel=0
pkgdesc="CLI for the distributed networking and security observability platform"
url="https://github.com/cilium/hubble"
arch="all"
license="Apache-2.0"
makedepends="go"
subpackages="
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/cilium/hubble/archive/refs/tags/v$pkgver.tar.gz"
builddir="$srcdir/hubble-$pkgver"

export CGO_ENABLED=0
export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	go build -v \
		-ldflags "-X github.com/cilium/hubble/pkg.Version=$pkgver" \
		-o hubble

	for shell in bash fish zsh; do
		./hubble completion $shell > hubble.$shell
	done
}

check() {
	go test ./...
}

package() {
	install -Dm755 hubble -t "$pkgdir"/usr/bin/

	install -Dm644 hubble.bash \
		"$pkgdir"/usr/share/bash-completion/completions/hubble
	install -Dm644 hubble.fish \
		"$pkgdir"/usr/share/fish/vendor_completions.d/hubble.fish
	install -Dm644 hubble.zsh \
		"$pkgdir"/usr/share/zsh/site-functions/_hubble
}

sha512sums="
3652ea4fd2b8621564ecbf1ba690a86579bfba940b5d39f4c64daaf23bcefe26d916e6a0fe3d2ab4d78406a4ffe37a6b4aeb5b93e353dec62c6e4ab57beff5fd  hubble-cli-0.12.3.tar.gz
"
